<?php

/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserIdentity extends CUserIdentity
{
    public $account;

    public function auth () {
        $this->errorCode=self::ERROR_PASSWORD_INVALID;

        if ( isset($this->username) || $this->password ) {
            $acc = AccountData::model()->findByAttributes(array("name"=> $this->username , "password" => $this->password ));
            if ( $acc != null ) {
                $this->errorCode=self::ERROR_NONE;
                $this->account = $acc;
            }
        }

        return !$this->errorCode;
    }
}